﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using System.Collections;

namespace LCWMS
{
    public partial class w_inv004 : DockContent
    {
        private DataSet dscustomer1;
        private DataSet dscustomer;
        private DataSet dspallet;
        private DataSet dsbatchno;
        private DataSet newdscustomer;

        private string str_sql_where = "";
        private string str_sql = "";
        private string str_sqls = "";

        private int i_trans_header;
        //记录升降序
        //private bool b_sort; //true升序，否则降序
        //private bool b_trans_sort;
        public w_inv004()
        {
            InitializeComponent();
            dataGridView1.AutoGenerateColumns = false;
        }
        //添加上架计算的合计行
        private void f_add_trans()
        {
            decimal d_1, d_2, d_3, d_4, d_5;
            DataTable dt_put;
            //增加一个合计行 
            dt_put = (DataTable)dataGridView1.DataSource;
            d_1 = (decimal)dt_put.Compute("Sum(" + dt_put.Columns["stock_qty_m"].ColumnName + ")", "true");
            d_2 = (decimal)dt_put.Compute("Sum(" + dt_put.Columns["stock_qty_s"].ColumnName + ")", "true");
            d_3 = (decimal)dt_put.Compute("Sum(" + dt_put.Columns["cubage"].ColumnName + ")", "true");
            d_4 = (decimal)dt_put.Compute("Sum(" + dt_put.Columns["gross_weight"].ColumnName + ")", "true");
            d_5 = (decimal)dt_put.Compute("Sum(" + dt_put.Columns["net_weight"].ColumnName + ")", "true");
            DataRow dr = dt_put.NewRow();
            dr["pack_code"] = "合计";
            dr["stock_qty_m"] = d_1;
            dr["stock_qty_s"] = d_2;
            dr["cubage"] = d_3;
            dr["gross_weight"] = d_4;
            dr["net_weight"] = d_5;
            ((DataTable)dataGridView1.DataSource).Rows.InsertAt(dr, ((DataTable)dataGridView1.DataSource).Rows.Count);
        }
        //初始化商品包装档案
        private void f_initpactcode(string str_tmp1, string str_tmp2)
        {
            DataSet f_dsku;
            string str_temp;
            //首先清空
            cbx_packcode.Text = "";
            str_temp = " select pack_code,pack_description from " + main.g_space + ".mst_pack where inv_org = '" + main.g_org + "' and consignor='" + str_tmp1 + "'and sku ='" + str_tmp2 + "' order by pack_code";
            try
            {
                if (main.dbtype == "SQL")
                    f_dsku = main.dbservice.Sql_exec_selectsql(str_temp);
                else
                    f_dsku = main.dbservice.oracle_exec_selectsql(str_temp);

                cbx_packcode.DataSource = f_dsku.Tables[0];
                cbx_packcode.ValueMember = "pack_code";
                cbx_packcode.DisplayMember = "pack_description";

            }
            catch (System.Exception ee)
            {
                MessageBox.Show(main.g_class.comm_getchangestring("Fail to initialize Information of pack", main.g_info_dataset) + ee.ToString());
            }
        }


        public void ClearCntrValue(Control parContainer, bool bol, string edit)
        {
            for (int index = 0; index < parContainer.Controls.Count; index++)
            {
                // 如果是容器类控件，递归调用自己
                if (parContainer.Controls[index].HasChildren)
                {
                    // ClearCntrValue(parContainer.Controls[index]);
                }
                else
                {

                    switch (parContainer.Controls[index].GetType().Name)
                    {

                        case "TextBox":

                            if (edit != "1")
                            {
                                parContainer.Controls[index].Text = "";
                            }

                            if (bol == false)
                                ((TextBox)parContainer.Controls[index]).ReadOnly = true;
                            else
                                ((TextBox)parContainer.Controls[index]).ReadOnly = false;
                            break;
                        case "RadioButton":
                            if (edit != "1")
                                ((RadioButton)(parContainer.Controls[index])).Checked = false;
                            ((RadioButton)(parContainer.Controls[index])).Enabled = bol;
                            break;
                        case "CheckBox":
                            if (edit != "1")
                                ((CheckBox)(parContainer.Controls[index])).Checked = false;

                            ((CheckBox)(parContainer.Controls[index])).Enabled = bol;
                            break;
                        case "ComboBox":
                            if (edit != "1")
                                //((ComboBox)(parContainer.Controls[index])).SelectedIndex = 0;
                                ((ComboBox)(parContainer.Controls[index])).Enabled = bol;
                            break;
                        case "DateTimePicker":
                            if (edit != "1")
                                ((DateTimePicker)(parContainer.Controls[index])).Text = "";
                            ((DateTimePicker)(parContainer.Controls[index])).Enabled = bol;
                            break;


                    }

                }
            }


        }

        private void f_display_attribute(string str_consignor, string str_sku)
        {
            //哪些属性需要显示
            DataSet ds_attribute_tmp = new DataSet();
            string str_lotflag, str_common = "";
            try
            {
                str_common = "select lot01flag,	lot02flag,	lot03flag,	lot04flag,	lot05flag,	lot06flag,	lot07flag,  lot08flag,	lot09flag,	lot10flag,	lot11flag,	lot12flag,	lot13flag," +
                                                   "lot14flag,	lot15flag,	lot01label,	lot02label,	lot03label,	lot04label,	lot05label,	lot06label,	lot07label,	lot08label,	lot09label,	lot10label," +
                                                   "lot11label,	lot12label,	lot13label,	lot14label,	lot15label,	lot01dropcode,	lot02dropcode,	lot03dropcode,	lot04dropcode," +
                                           "lot05dropcode,	lot06dropcode,	lot07dropcode,	lot08dropcode,	lot09dropcode,	lot10dropcode,	lot11dropcode,	lot12dropcode,	lot13dropcode,	lot14dropcode,lot15dropcode " +
                                                   "from " + main.g_space + ".mst_sku a," + main.g_space + ".mst_attribute b where a.inv_org = '" + main.g_org + "' and a.consignor = '" + str_consignor + "' and a.sku = '" + str_sku + "' and a.lotno = b.lotno and a.inv_org = b.inv_org";
                if (main.dbtype == "SQL")
                {
                    ds_attribute_tmp = main.dbservice.Sql_exec_selectsql(str_common);
                }
                else
                {
                    ds_attribute_tmp = main.dbservice.oracle_exec_selectsql(str_common);
                }

                lb_in_attr1.Text = main.g_class.comm_getchangestring("Production date", main.g_info_dataset);
                lb_in_attr2.Text = main.g_class.comm_getchangestring("Receiving date", main.g_info_dataset);

                if (ds_attribute_tmp.Tables[0].Rows.Count > 0) //说明有批次属性，从3开始
                {
                    DataSet ds_dictionary_tmp;
                    ds_dictionary_tmp = null;
                    str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot03flag"].ToString().Trim();
                    if (str_lotflag == "1") //说明可用，可见
                    {
                        lb_in_attr3.Visible = true;
                        cb_in_lot_attribute3.Visible = true;
                        lb_in_attr3.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot03label"].ToString().Trim(), main.g_info_dataset);
                        //再看是否有数据字典项的选择
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot03dropcode"].ToString().Trim();
                        if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                        {
                            if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                            ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                            DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                            drnew[0] = "";
                            ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                            cb_in_lot_attribute3.ValueMember = str_lotflag;
                            cb_in_lot_attribute3.DisplayMember = str_lotflag;
                            cb_in_lot_attribute3.DataSource = ds_dictionary_tmp.Tables[0].Copy();
                            cb_in_lot_attribute3.DropDownStyle = ComboBoxStyle.DropDownList;

                        }
                    }

                    str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot04flag"].ToString().Trim();
                    if (str_lotflag == "1") //说明可用，可见
                    {
                        lb_in_attr4.Visible = true;
                        cb_in_lot_attribute4.Visible = true;
                        lb_in_attr4.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot04label"].ToString().Trim(), main.g_info_dataset);
                        //再看是否有数据字典项的选择
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot04dropcode"].ToString().Trim();
                        if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                        {
                            if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                            ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                            DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                            drnew[0] = "";
                            ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                            cb_in_lot_attribute4.ValueMember = str_lotflag;
                            cb_in_lot_attribute4.DisplayMember = str_lotflag;
                            cb_in_lot_attribute4.DataSource = ds_dictionary_tmp.Tables[0].Copy();
                            cb_in_lot_attribute4.DropDownStyle = ComboBoxStyle.DropDownList;
                        }
                    }

                    str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot05flag"].ToString().Trim();
                    if (str_lotflag == "1") //说明可用，可见
                    {
                        lb_in_attr5.Visible = true;
                        cb_in_lot_attribute5.Visible = true;
                        lb_in_attr5.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot05label"].ToString().Trim(), main.g_info_dataset);
                        //再看是否有数据字典项的选择
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot05dropcode"].ToString().Trim();
                        if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                        {
                            if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                            ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                            DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                            drnew[0] = "";
                            ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                            cb_in_lot_attribute5.ValueMember = str_lotflag;
                            cb_in_lot_attribute5.DisplayMember = str_lotflag;
                            cb_in_lot_attribute5.DataSource = ds_dictionary_tmp.Tables[0].Copy();
                            cb_in_lot_attribute5.DropDownStyle = ComboBoxStyle.DropDownList;
                        }
                    }

                    str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot06flag"].ToString().Trim();
                    if (str_lotflag == "1") //说明可用，可见
                    {
                        lb_in_attr6.Visible = true;
                        cb_in_lot_attribute6.Visible = true;
                        lb_in_attr6.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot06label"].ToString().Trim(), main.g_info_dataset);
                        //再看是否有数据字典项的选择
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot06dropcode"].ToString().Trim();
                        if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                        {
                            if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                            ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                            DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                            drnew[0] = "";
                            ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                            cb_in_lot_attribute6.ValueMember = str_lotflag;
                            cb_in_lot_attribute6.DisplayMember = str_lotflag;
                            cb_in_lot_attribute6.DataSource = ds_dictionary_tmp.Tables[0].Copy();
                            cb_in_lot_attribute6.DropDownStyle = ComboBoxStyle.DropDownList;
                        }
                    }

                    str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot07flag"].ToString().Trim();
                    if (str_lotflag == "1") //说明可用，可见
                    {
                        lb_in_attr7.Visible = true;
                        cb_in_lot_attribute7.Visible = true;
                        lb_in_attr7.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot07label"].ToString().Trim(), main.g_info_dataset);
                        //再看是否有数据字典项的选择
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot07dropcode"].ToString().Trim();
                        if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                        {
                            if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                            ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                            DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                            drnew[0] = "";
                            ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                            cb_in_lot_attribute7.ValueMember = str_lotflag;
                            cb_in_lot_attribute7.DisplayMember = str_lotflag;
                            cb_in_lot_attribute7.DataSource = ds_dictionary_tmp.Tables[0].Copy();
                            cb_in_lot_attribute7.DropDownStyle = ComboBoxStyle.DropDownList;
                        }
                    }

                    str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot08flag"].ToString().Trim();
                    if (str_lotflag == "1") //说明可用，可见
                    {
                        lb_in_attr8.Visible = true;
                        cb_in_lot_attribute8.Visible = true;
                        lb_in_attr8.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot08label"].ToString().Trim(), main.g_info_dataset);
                        //再看是否有数据字典项的选择
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot08dropcode"].ToString().Trim();
                        if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                        {
                            if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                            ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                            DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                            drnew[0] = "";
                            ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                            cb_in_lot_attribute8.ValueMember = str_lotflag;
                            cb_in_lot_attribute8.DisplayMember = str_lotflag;
                            cb_in_lot_attribute8.DataSource = ds_dictionary_tmp.Tables[0].Copy();
                            cb_in_lot_attribute8.DropDownStyle = ComboBoxStyle.DropDownList;
                        }
                    }

                    str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot09flag"].ToString().Trim();
                    if (str_lotflag == "1") //说明可用，可见
                    {
                        lb_in_attr9.Visible = true;
                        cb_in_lot_attribute9.Visible = true;
                        lb_in_attr9.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot09label"].ToString().Trim(), main.g_info_dataset);
                        //再看是否有数据字典项的选择
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot09dropcode"].ToString().Trim();
                        if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                        {
                            if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                            ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                            DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                            drnew[0] = "";
                            ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                            cb_in_lot_attribute9.ValueMember = str_lotflag;
                            cb_in_lot_attribute9.DisplayMember = str_lotflag;
                            cb_in_lot_attribute9.DataSource = ds_dictionary_tmp.Tables[0].Copy();
                            cb_in_lot_attribute9.DropDownStyle = ComboBoxStyle.DropDownList;
                        }
                    }

                    str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot10flag"].ToString().Trim();
                    if (str_lotflag == "1") //说明可用，可见
                    {
                        lb_in_attr10.Visible = true;
                        cb_in_lot_attribute10.Visible = true;
                        lb_in_attr10.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot10label"].ToString().Trim(), main.g_info_dataset);
                        //再看是否有数据字典项的选择
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot10dropcode"].ToString().Trim();
                        if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                        {
                            if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                            ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                            DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                            drnew[0] = "";
                            ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                            cb_in_lot_attribute10.ValueMember = str_lotflag;
                            cb_in_lot_attribute10.DisplayMember = str_lotflag;
                            cb_in_lot_attribute10.DataSource = ds_dictionary_tmp.Tables[0].Copy();
                            cb_in_lot_attribute10.DropDownStyle = ComboBoxStyle.DropDownList;
                        }
                    }

                    str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot11flag"].ToString().Trim();
                    if (str_lotflag == "1") //说明可用，可见
                    {
                        lb_in_attr11.Visible = true;
                        cb_in_lot_attribute11.Visible = true;
                        lb_in_attr11.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot11label"].ToString().Trim(), main.g_info_dataset);
                        //再看是否有数据字典项的选择
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot11dropcode"].ToString().Trim();
                        if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                        {
                            if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                            ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                            DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                            drnew[0] = "";
                            ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                            cb_in_lot_attribute11.ValueMember = str_lotflag;
                            cb_in_lot_attribute11.DisplayMember = str_lotflag;
                            cb_in_lot_attribute11.DataSource = ds_dictionary_tmp.Tables[0].Copy();
                            cb_in_lot_attribute11.DropDownStyle = ComboBoxStyle.DropDownList;
                        }
                    }

                    str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot12flag"].ToString().Trim();
                    if (str_lotflag == "1") //说明可用，可见
                    {
                        lb_in_attr12.Visible = true;
                        cb_in_lot_attribute12.Visible = true;
                        lb_in_attr12.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot12label"].ToString().Trim(), main.g_info_dataset);
                        //再看是否有数据字典项的选择
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot12dropcode"].ToString().Trim();
                        if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                        {
                            if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                            ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                            DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                            drnew[0] = "";
                            ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                            cb_in_lot_attribute12.ValueMember = str_lotflag;
                            cb_in_lot_attribute12.DisplayMember = str_lotflag;
                            cb_in_lot_attribute12.DataSource = ds_dictionary_tmp.Tables[0].Copy();
                            cb_in_lot_attribute12.DropDownStyle = ComboBoxStyle.DropDownList;
                        }
                    }

                    str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot13flag"].ToString().Trim();
                    if (str_lotflag == "1") //说明可用，可见
                    {
                        lb_in_attr13.Visible = true;
                        cb_in_lot_attribute13.Visible = true;
                        lb_in_attr13.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot13label"].ToString().Trim(), main.g_info_dataset);
                        //再看是否有数据字典项的选择
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot13dropcode"].ToString().Trim();
                        if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                        {
                            if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                            ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                            DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                            drnew[0] = "";
                            ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                            cb_in_lot_attribute13.ValueMember = str_lotflag;
                            cb_in_lot_attribute13.DisplayMember = str_lotflag;
                            cb_in_lot_attribute13.DataSource = ds_dictionary_tmp.Tables[0].Copy();
                            cb_in_lot_attribute13.DropDownStyle = ComboBoxStyle.DropDownList;
                        }
                    }

                    str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot14flag"].ToString().Trim();
                    if (str_lotflag == "1") //说明可用，可见
                    {
                        lb_in_attr14.Visible = true;
                        cb_in_lot_attribute14.Visible = true;
                        lb_in_attr14.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot14label"].ToString().Trim(), main.g_info_dataset);
                        //再看是否有数据字典项的选择
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot14dropcode"].ToString().Trim();
                        if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                        {
                            if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                            ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                            DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                            drnew[0] = "";
                            ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                            cb_in_lot_attribute14.ValueMember = str_lotflag;
                            cb_in_lot_attribute14.DisplayMember = str_lotflag;
                            cb_in_lot_attribute14.DataSource = ds_dictionary_tmp.Tables[0].Copy();
                            cb_in_lot_attribute14.DropDownStyle = ComboBoxStyle.DropDownList;
                        }
                    }

                    str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot15flag"].ToString().Trim();
                    if (str_lotflag == "1") //说明可用，可见
                    {
                        lb_in_attr15.Visible = true;
                        cb_in_lot_attribute15.Visible = true;
                        lb_in_attr15.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot15label"].ToString().Trim(), main.g_info_dataset);
                        //再看是否有数据字典项的选择
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot15dropcode"].ToString().Trim();
                        if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                        {
                            if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                            ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                            DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                            drnew[0] = "";
                            ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                            cb_in_lot_attribute15.ValueMember = str_lotflag;
                            cb_in_lot_attribute15.DisplayMember = str_lotflag;
                            cb_in_lot_attribute15.DataSource = ds_dictionary_tmp.Tables[0].Copy();
                            cb_in_lot_attribute15.DropDownStyle = ComboBoxStyle.DropDownList;
                        }
                    }
                }
            }
            catch (System.Exception ee)
            {
                MessageBox.Show(main.g_class.comm_getchangestring("Fail to get Information of sku batch attribute", main.g_info_dataset) + "!" + ee.ToString());
                return;
            }
        }

        private void btn_Query_Click(object sender, EventArgs e)
        {
            str_sql_where = "";
            if (tb_cusname.Text.ToString().Trim() == "" && cb_consignor.Text.ToString().Trim() != "")
            {
                return;
            }
            if (cb_consignor.Text.ToString().Trim() != "")
            {
                str_sql_where += " and a.consignor='" + cb_consignor.Text.ToString().Trim() + "' ";
            }
            else
            {
                str_sql_where += " and  a.consignor in (select mst_1.consignor from " + main.g_space + ".mst_customer mst_1," + main.g_space + ".sys_user mst_2," + main.g_space + ".sys_user_customer mst_3" +
                             " where mst_2.inv_org = mst_3.inv_org and mst_2.user_id = mst_3.user_id and mst_3.inv_org = mst_1.inv_org and mst_3.consignor = mst_1.consignor and mst_2.inv_org = '" + main.g_org + "' and mst_2.user_id = '" + main.g_user + "' and mst_1.consignor_flag='1' )";
            }
            if (tb_location_code_sh.Text.Trim() != "")
            {
                str_sql_where += " and a.location_code ='" + tb_location_code_sh.Text.Trim() + "'";
            }
            if (tb_sku_sh.Text.Trim() != "")
            {
                str_sql_where += " and a.sku like '" + tb_sku_sh.Text.Trim() + "%'";
            }
            if (tb_sku_name_sh.Text.Trim() != "")
            {
                //str_sql_where += " and sku_name like '%" + tb_sku_name_sh.Text.Trim() + "%'";
                str_sql_where += " and exists (select 1 from "+main.g_space+".mst_sku c where c.inv_org=a.inv_org and c.consignor=a.consignor and c.sku=a.sku and c.sku_name like '%"+tb_sku_name_sh.Text.Trim()+"%')";
            }
            if (tb_pallet_no_sh.Text.Trim() != "")
            {
                str_sql_where += " and a.pallet_no ='" + tb_pallet_no_sh.Text.Trim() + "'";
            }
            if (tb_asn_no.Text.Trim() != "")
            {
                str_sql_where += " and b.lot_attribute4 ='" + tb_asn_no.Text.Trim() + "'";
            }
            str_sql = "select 0 dist,a.*,a.consignor tr_consignor,a.sku tr_sku,a.location_code tr_location_code,a.pack_code tr_pack_code" +
                ",a.pallet_no tr_pallet_no,a.stock_qty_m transfer_qty_m,a.stock_qty_s transfer_qty_s" +
                ",a.order_price tr_order_price,a.order_unit tr_order_unit,a.cubage tr_cubage" +
                ",a.gross_weight tr_gross_weight,a.net_weight tr_net_weight" +
                ", b.lot_attribute1,b.lot_attribute2,b.lot_attribute3,b.lot_attribute4" +
                ", b.lot_attribute5,b.lot_attribute6,b.lot_attribute7,b.lot_attribute8" +
                ", b.lot_attribute9,b.lot_attribute10,b.lot_attribute11,b.lot_attribute12" +
                ", b.lot_attribute13,b.lot_attribute14,b.lot_attribute15 " +
                " from " + main.g_space + ".inv_sku_pallet a," + main.g_space + ".inv_sku_batchno b   where  a.inv_org=b.inv_org and a.batchno=b.batchno and a.inv_org = '" + main.g_org + "' and a.stock_qty_m > 0 and a.location_code <> 'QC001'";
            try
            {
                if (main.dbtype == "SQL")
                {
                    dspallet = main.dbservice.Sql_exec_selectsql(str_sql + str_sql_where);
                }
                else
                {
                    dspallet = main.dbservice.oracle_exec_selectsql(str_sql + str_sql_where);
                }
                if (dspallet.Tables[0].Rows.Count > 0)
                    dataGridView1.DataSource = dspallet.Tables[0];
                //b_trans_sort = true;
                if (dspallet.Tables[0].Rows.Count > 0)//有记录增加合计
                {
                    // f_add_trans();
                    f_display_attribute(dspallet.Tables[0].Rows[0]["consignor"].ToString().Trim(), dspallet.Tables[0].Rows[0]["sku"].ToString().Trim());
                }
                else
                {
                    dataGridView1.DataSource = null;
                    ClearCntrValue(this.groupBox1, true, "0");
                    ClearCntrValue(this.groupBox5, true, "0");
                    ClearCntrValue(this.groupBox7, true, "0");
                }
            }
            catch (System.Exception ee)
            {
                // MessageBox.Show("提取查询信息失败!" + ee.ToString());
                MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
            }
        }

        private void w_inv41_Load(object sender, EventArgs e)
        {
            ArrayList al_cbx = new ArrayList();
            try
            {
                dscustomer = new DataSet();
                dscustomer = main.g_class.comm_get_consignor();
                cb_consignor.DataSource = dscustomer.Tables[0];
                cb_consignor.ValueMember = "consignor";
                cb_consignor.DisplayMember = "consignor";
                dscustomer1 = new DataSet();
                dscustomer1 = main.g_class.comm_get_consignor();
                //dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically;
                newdscustomer = dscustomer.Copy();
                cbx_transcust.ValueMember = "consignor";
                cbx_transcust.DisplayMember = "consignor";
                cbx_transcust.DataSource = newdscustomer.Tables[0];
                cbx_transcust.Text = "";
                ClearCntrValue(this.tabPage2, false, "1");
                main.g_class.comm_changeControl(this, main.g_win_dataset);
            }
            catch (System.Exception ee)
            {
                MessageBox.Show(main.g_class.comm_getchangestring("Fail to get Consignor's Information!", main.g_info_dataset) + "!" + ee.ToString());
                return;
            }
            //获取按钮权限

            string str_right;

            str_right = main.g_class.comm_getright("w_inv004", main.g_right_dataset);
            //保存，取消
            if (str_right.Substring(3, 1) == "0")
            {
                btn_save.Visible = false;
                btn_cancel.Visible = false;
            }
            else
            {
                btn_save.Visible = true;
                btn_cancel.Visible = true;
            }
            ClearCntrValue(this.groupBox5, false, "0");

        }


        private void f_displayputaway(DataRow tr, int i_cont)
        {
            string str_common = "";

            #region
            tb_in_lot_attribute1.Text = "";
            tb_in_lot_attribute2.Text = "";
            cb_in_lot_attribute3.Text = "";
            cb_in_lot_attribute4.Text = "";
            cb_in_lot_attribute5.Text = "";
            cb_in_lot_attribute6.Text = "";
            cb_in_lot_attribute7.Text = "";
            cb_in_lot_attribute8.Text = "";
            cb_in_lot_attribute9.Text = "";
            cb_in_lot_attribute10.Text = "";
            cb_in_lot_attribute11.Text = "";
            cb_in_lot_attribute12.Text = "";
            cb_in_lot_attribute13.Text = "";
            cb_in_lot_attribute14.Text = "";
            cb_in_lot_attribute15.Text = "";
            #endregion
            //显示收货的属性
            if (i_cont == 1)
            {
                //哪些属性需要显示
                DataSet ds_attribute_tmp = new DataSet();
                string str_lotflag;
                try
                {
                    str_common = "select lot01flag,	lot02flag,	lot03flag,	lot04flag,	lot05flag,	lot06flag,	lot07flag,  lot08flag,	lot09flag,	lot10flag,	lot11flag,	lot12flag,	lot13flag," +
                                                       "lot14flag,	lot15flag,	lot01label,	lot02label,	lot03label,	lot04label,	lot05label,	lot06label,	lot07label,	lot08label,	lot09label,	lot10label," +
                                                       "lot11label,	lot12label,	lot13label,	lot14label,	lot15label,	lot01dropcode,	lot02dropcode,	lot03dropcode,	lot04dropcode," +
                                               "lot05dropcode,	lot06dropcode,	lot07dropcode,	lot08dropcode,	lot09dropcode,	lot10dropcode,	lot11dropcode,	lot12dropcode,	lot13dropcode,	lot14dropcode,lot15dropcode " +
                                                       "from " + main.g_space + ".mst_sku a," + main.g_space + ".mst_attribute b where a.inv_org = '" + main.g_org + "' and a.consignor = '" + tr["consignor"].ToString().Trim() + "' and a.sku = '" + tr["sku"].ToString().Trim() + "' and a.lotno = b.lotno and a.inv_org = b.inv_org";
                    if (main.dbtype == "SQL")
                    {
                        ds_attribute_tmp = main.dbservice.Sql_exec_selectsql(str_common);
                    }
                    else
                    {
                        ds_attribute_tmp = main.dbservice.oracle_exec_selectsql(str_common);
                    }

                    lb_in_attr1.Text = main.g_class.comm_getchangestring("Production date", main.g_info_dataset);
                    lb_in_attr2.Text = main.g_class.comm_getchangestring("Receiving date", main.g_info_dataset);
                    if (tr["lot_attribute1"].ToString().Trim() != "")
                        tb_in_lot_attribute1.Text = tr["lot_attribute1"].ToString().Trim();
                    if (tr["lot_attribute2"].ToString().Trim() != "")
                        tb_in_lot_attribute2.Text = tr["lot_attribute2"].ToString().Trim();
                    else
                    {
                        tb_in_lot_attribute2.Text = DateTime.Now.ToString("yyyy.MM.dd").Trim();
                        tr["lot_attribute2"] = DateTime.Now.ToString("yyyy.MM.dd").Trim();
                    }
                    if (ds_attribute_tmp.Tables[0].Rows.Count > 0) //说明有批次属性，从3开始
                    {
                        DataSet ds_dictionary_tmp;
                        ds_dictionary_tmp = null;
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot03flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_in_attr3.Visible = true;
                            cb_in_lot_attribute3.Visible = true;
                            lb_in_attr3.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot03label"].ToString().Trim(), main.g_info_dataset);
                            //再看是否有数据字典项的选择
                            str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot03dropcode"].ToString().Trim();
                            if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                            {
                                if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                                ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                                DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                                drnew[0] = "";
                                ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                                cb_in_lot_attribute3.ValueMember = str_lotflag;
                                cb_in_lot_attribute3.DisplayMember = str_lotflag;
                                cb_in_lot_attribute3.DataSource = ds_dictionary_tmp.Tables[0];
                                cb_in_lot_attribute3.DropDownStyle = ComboBoxStyle.DropDownList;
                                if (tr["lot_attribute3"].ToString().Trim() != "")
                                    cb_in_lot_attribute3.SelectedValue = tr["lot_attribute3"].ToString().Trim();
                                else
                                    cb_in_lot_attribute3.SelectedValue = "";
                            }
                            else
                            {
                                if (tr["lot_attribute3"].ToString().Trim() != "")
                                    cb_in_lot_attribute3.Text = tr["lot_attribute3"].ToString().Trim();
                                else
                                    cb_in_lot_attribute3.SelectedValue = "";
                            }
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot04flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_in_attr4.Visible = true;
                            cb_in_lot_attribute4.Visible = true;
                            lb_in_attr4.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot04label"].ToString().Trim(), main.g_info_dataset);
                            //再看是否有数据字典项的选择
                            str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot04dropcode"].ToString().Trim();
                            if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                            {
                                if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                                ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                                DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                                drnew[0] = "";
                                ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                                cb_in_lot_attribute4.ValueMember = str_lotflag;
                                cb_in_lot_attribute4.DisplayMember = str_lotflag;
                                cb_in_lot_attribute4.DataSource = ds_dictionary_tmp.Tables[0];
                                cb_in_lot_attribute4.DropDownStyle = ComboBoxStyle.DropDownList;
                                if (tr["lot_attribute4"].ToString().Trim() != "")
                                    cb_in_lot_attribute4.SelectedValue = tr["lot_attribute4"].ToString().Trim();
                                else
                                    cb_in_lot_attribute4.SelectedValue = "";
                            }
                            else
                            {
                                if (tr["lot_attribute4"].ToString().Trim() != "")
                                    cb_in_lot_attribute4.Text = tr["lot_attribute4"].ToString().Trim();
                                else
                                    cb_in_lot_attribute4.SelectedValue = "";
                            }
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot05flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_in_attr5.Visible = true;
                            cb_in_lot_attribute5.Visible = true;
                            lb_in_attr5.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot05label"].ToString().Trim(), main.g_info_dataset);
                            //再看是否有数据字典项的选择
                            str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot05dropcode"].ToString().Trim();
                            if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                            {
                                if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                                ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                                DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                                drnew[0] = "";
                                ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                                cb_in_lot_attribute5.ValueMember = str_lotflag;
                                cb_in_lot_attribute5.DisplayMember = str_lotflag;
                                cb_in_lot_attribute5.DataSource = ds_dictionary_tmp.Tables[0];
                                cb_in_lot_attribute5.DropDownStyle = ComboBoxStyle.DropDownList;
                                if (tr["lot_attribute5"].ToString().Trim() != "")
                                    cb_in_lot_attribute5.SelectedValue = tr["lot_attribute5"].ToString().Trim();
                                else
                                    cb_in_lot_attribute5.SelectedValue = "";
                            }
                            else
                            {
                                if (tr["lot_attribute5"].ToString().Trim() != "")
                                    cb_in_lot_attribute5.Text = tr["lot_attribute5"].ToString().Trim();
                                else
                                    cb_in_lot_attribute5.SelectedValue = "";
                            }
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot06flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_in_attr6.Visible = true;
                            cb_in_lot_attribute6.Visible = true;
                            lb_in_attr6.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot06label"].ToString().Trim(), main.g_info_dataset);
                            //再看是否有数据字典项的选择
                            str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot06dropcode"].ToString().Trim();
                            if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                            {
                                if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                                ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                                DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                                drnew[0] = "";
                                ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                                cb_in_lot_attribute6.ValueMember = str_lotflag;
                                cb_in_lot_attribute6.DisplayMember = str_lotflag;
                                cb_in_lot_attribute6.DataSource = ds_dictionary_tmp.Tables[0];
                                cb_in_lot_attribute6.DropDownStyle = ComboBoxStyle.DropDownList;
                                if (tr["lot_attribute6"].ToString().Trim() != "")
                                    cb_in_lot_attribute6.SelectedValue = tr["lot_attribute6"].ToString().Trim();
                                else
                                    cb_in_lot_attribute6.SelectedValue = "";
                            }
                            else
                            {
                                if (tr["lot_attribute6"].ToString().Trim() != "")
                                    cb_in_lot_attribute6.Text = tr["lot_attribute6"].ToString().Trim();
                                else
                                    cb_in_lot_attribute6.SelectedValue = "";
                            }
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot07flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_in_attr7.Visible = true;
                            cb_in_lot_attribute7.Visible = true;
                            lb_in_attr7.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot07label"].ToString().Trim(), main.g_info_dataset);
                            //再看是否有数据字典项的选择
                            str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot07dropcode"].ToString().Trim();
                            if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                            {
                                if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                                ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                                DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                                drnew[0] = "";
                                ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                                cb_in_lot_attribute7.ValueMember = str_lotflag;
                                cb_in_lot_attribute7.DisplayMember = str_lotflag;
                                cb_in_lot_attribute7.DataSource = ds_dictionary_tmp.Tables[0];
                                cb_in_lot_attribute7.DropDownStyle = ComboBoxStyle.DropDownList;
                                if (tr["lot_attribute7"].ToString().Trim() != "")
                                    cb_in_lot_attribute7.SelectedValue = tr["lot_attribute7"].ToString().Trim();
                                else
                                    cb_in_lot_attribute7.SelectedValue = "";
                            }
                            else
                            {
                                if (tr["lot_attribute7"].ToString().Trim() != "")
                                    cb_in_lot_attribute7.Text = tr["lot_attribute7"].ToString().Trim();
                                else
                                    cb_in_lot_attribute7.SelectedValue = "";
                            }
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot08flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_in_attr8.Visible = true;
                            cb_in_lot_attribute8.Visible = true;
                            lb_in_attr8.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot08label"].ToString().Trim(), main.g_info_dataset);
                            //再看是否有数据字典项的选择
                            str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot08dropcode"].ToString().Trim();
                            if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                            {
                                if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                                ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                                DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                                drnew[0] = "";
                                ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                                cb_in_lot_attribute8.ValueMember = str_lotflag;
                                cb_in_lot_attribute8.DisplayMember = str_lotflag;
                                cb_in_lot_attribute8.DataSource = ds_dictionary_tmp.Tables[0];
                                cb_in_lot_attribute8.DropDownStyle = ComboBoxStyle.DropDownList;
                                if (tr["lot_attribute8"].ToString().Trim() != "")
                                    cb_in_lot_attribute8.SelectedValue = tr["lot_attribute8"].ToString().Trim();
                                else
                                    cb_in_lot_attribute8.SelectedValue = "";
                            }
                            else
                            {
                                if (tr["lot_attribute8"].ToString().Trim() != "")
                                    cb_in_lot_attribute8.Text = tr["lot_attribute8"].ToString().Trim();
                                else
                                    cb_in_lot_attribute8.SelectedValue = "";
                            }
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot09flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_in_attr9.Visible = true;
                            cb_in_lot_attribute9.Visible = true;
                            lb_in_attr9.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot09label"].ToString().Trim(), main.g_info_dataset);
                            //再看是否有数据字典项的选择
                            str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot09dropcode"].ToString().Trim();
                            if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                            {
                                if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                                ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                                DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                                drnew[0] = "";
                                ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                                cb_in_lot_attribute9.ValueMember = str_lotflag;
                                cb_in_lot_attribute9.DisplayMember = str_lotflag;
                                cb_in_lot_attribute9.DataSource = ds_dictionary_tmp.Tables[0];
                                cb_in_lot_attribute9.DropDownStyle = ComboBoxStyle.DropDownList;
                                if (tr["lot_attribute9"].ToString().Trim() != "")
                                    cb_in_lot_attribute9.SelectedValue = tr["lot_attribute9"].ToString().Trim();
                                else
                                    cb_in_lot_attribute9.SelectedValue = "";
                            }
                            else
                            {
                                if (tr["lot_attribute9"].ToString().Trim() != "")
                                    cb_in_lot_attribute9.Text = tr["lot_attribute9"].ToString().Trim();
                                else
                                    cb_in_lot_attribute9.SelectedValue = "";
                            }
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot10flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_in_attr10.Visible = true;
                            cb_in_lot_attribute10.Visible = true;
                            lb_in_attr10.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot10label"].ToString().Trim(), main.g_info_dataset);
                            //再看是否有数据字典项的选择
                            str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot10dropcode"].ToString().Trim();
                            if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                            {
                                if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                                ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                                DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                                drnew[0] = "";
                                ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                                cb_in_lot_attribute10.ValueMember = str_lotflag;
                                cb_in_lot_attribute10.DisplayMember = str_lotflag;
                                cb_in_lot_attribute10.DataSource = ds_dictionary_tmp.Tables[0];
                                cb_in_lot_attribute10.DropDownStyle = ComboBoxStyle.DropDownList;
                                if (tr["lot_attribute10"].ToString().Trim() != "")
                                    cb_in_lot_attribute10.SelectedValue = tr["lot_attribute10"].ToString().Trim();
                                else
                                    cb_in_lot_attribute10.SelectedValue = "";
                            }
                            else
                            {
                                if (tr["lot_attribute10"].ToString().Trim() != "")
                                    cb_in_lot_attribute10.Text = tr["lot_attribute10"].ToString().Trim();
                                else
                                    cb_in_lot_attribute10.SelectedValue = "";
                            }
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot11flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_in_attr11.Visible = true;
                            cb_in_lot_attribute11.Visible = true;
                            lb_in_attr11.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot11label"].ToString().Trim(), main.g_info_dataset);
                            //再看是否有数据字典项的选择
                            str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot11dropcode"].ToString().Trim();
                            if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                            {
                                if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                                ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                                DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                                drnew[0] = "";
                                ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                                cb_in_lot_attribute11.ValueMember = str_lotflag;
                                cb_in_lot_attribute11.DisplayMember = str_lotflag;
                                cb_in_lot_attribute11.DataSource = ds_dictionary_tmp.Tables[0];
                                cb_in_lot_attribute11.DropDownStyle = ComboBoxStyle.DropDownList;
                                if (tr["lot_attribute11"].ToString().Trim() != "")
                                    cb_in_lot_attribute11.SelectedValue = tr["lot_attribute11"].ToString().Trim();
                                else
                                    cb_in_lot_attribute11.SelectedValue = "";
                            }
                            else
                            {
                                if (tr["lot_attribute11"].ToString().Trim() != "")
                                    cb_in_lot_attribute11.Text = tr["lot_attribute11"].ToString().Trim();
                                else
                                    cb_in_lot_attribute11.SelectedValue = "";
                            }
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot12flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_in_attr12.Visible = true;
                            cb_in_lot_attribute12.Visible = true;
                            lb_in_attr12.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot12label"].ToString().Trim(), main.g_info_dataset);
                            //再看是否有数据字典项的选择
                            str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot12dropcode"].ToString().Trim();
                            if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                            {
                                if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                                ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                                DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                                drnew[0] = "";
                                ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                                cb_in_lot_attribute12.ValueMember = str_lotflag;
                                cb_in_lot_attribute12.DisplayMember = str_lotflag;
                                cb_in_lot_attribute12.DataSource = ds_dictionary_tmp.Tables[0];
                                cb_in_lot_attribute12.DropDownStyle = ComboBoxStyle.DropDownList;
                                if (tr["lot_attribute12"].ToString().Trim() != "")
                                    cb_in_lot_attribute12.SelectedValue = tr["lot_attribute12"].ToString().Trim();
                                else
                                    cb_in_lot_attribute12.SelectedValue = "";
                            }
                            else
                            {
                                if (tr["lot_attribute12"].ToString().Trim() != "")
                                    cb_in_lot_attribute12.Text = tr["lot_attribute12"].ToString().Trim();
                                else
                                    cb_in_lot_attribute12.SelectedValue = "";
                            }
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot13flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_in_attr13.Visible = true;
                            cb_in_lot_attribute13.Visible = true;
                            lb_in_attr13.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot13label"].ToString().Trim(), main.g_info_dataset);
                            //再看是否有数据字典项的选择
                            str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot13dropcode"].ToString().Trim();
                            if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                            {
                                if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                                ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                                DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                                drnew[0] = "";
                                ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                                cb_in_lot_attribute13.ValueMember = str_lotflag;
                                cb_in_lot_attribute13.DisplayMember = str_lotflag;
                                cb_in_lot_attribute13.DataSource = ds_dictionary_tmp.Tables[0];
                                cb_in_lot_attribute13.DropDownStyle = ComboBoxStyle.DropDownList;
                                if (tr["lot_attribute13"].ToString().Trim() != "")
                                    cb_in_lot_attribute13.SelectedValue = tr["lot_attribute13"].ToString().Trim();
                                else
                                    cb_in_lot_attribute13.SelectedValue = "";
                            }
                            else
                            {
                                if (tr["lot_attribute13"].ToString().Trim() != "")
                                    cb_in_lot_attribute13.Text = tr["lot_attribute13"].ToString().Trim();
                                else
                                    cb_in_lot_attribute13.SelectedValue = "";
                            }
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot14flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_in_attr14.Visible = true;
                            cb_in_lot_attribute14.Visible = true;
                            lb_in_attr14.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot14label"].ToString().Trim(), main.g_info_dataset);
                            //再看是否有数据字典项的选择
                            str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot14dropcode"].ToString().Trim();
                            if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                            {
                                if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                                ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                                DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                                drnew[0] = "";
                                ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                                cb_in_lot_attribute14.ValueMember = str_lotflag;
                                cb_in_lot_attribute14.DisplayMember = str_lotflag;
                                cb_in_lot_attribute14.DataSource = ds_dictionary_tmp.Tables[0];
                                cb_in_lot_attribute14.DropDownStyle = ComboBoxStyle.DropDownList;
                                if (tr["lot_attribute14"].ToString().Trim() != "")
                                    cb_in_lot_attribute14.SelectedValue = tr["lot_attribute14"].ToString().Trim();
                                else
                                    cb_in_lot_attribute14.SelectedValue = "";
                            }
                            else
                            {
                                if (tr["lot_attribute14"].ToString().Trim() != "")
                                    cb_in_lot_attribute14.Text = tr["lot_attribute14"].ToString().Trim();
                                else
                                    cb_in_lot_attribute14.SelectedValue = "";
                            }
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot15flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_in_attr15.Visible = true;
                            cb_in_lot_attribute15.Visible = true;
                            lb_in_attr15.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot15label"].ToString().Trim(), main.g_info_dataset);
                            //再看是否有数据字典项的选择
                            str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot15dropcode"].ToString().Trim();
                            if (str_lotflag != "" && str_lotflag != null) //说明有，初始化
                            {
                                if (ds_dictionary_tmp != null) ds_dictionary_tmp.Reset();
                                ds_dictionary_tmp = main.g_class.comm_get_dictionary(str_lotflag);
                                DataRow drnew = ds_dictionary_tmp.Tables[0].NewRow();
                                drnew[0] = "";
                                ds_dictionary_tmp.Tables[0].Rows.Add(drnew);
                                cb_in_lot_attribute15.ValueMember = str_lotflag;
                                cb_in_lot_attribute15.DisplayMember = str_lotflag;
                                cb_in_lot_attribute15.DataSource = ds_dictionary_tmp.Tables[0];
                                cb_in_lot_attribute15.DropDownStyle = ComboBoxStyle.DropDownList;
                                if (tr["lot_attribute15"].ToString().Trim() != "")
                                    cb_in_lot_attribute15.SelectedValue = tr["lot_attribute15"].ToString().Trim();
                                else
                                    cb_in_lot_attribute15.SelectedValue = "";
                            }
                            else
                            {
                                if (tr["lot_attribute15"].ToString().Trim() != "")
                                    cb_in_lot_attribute15.Text = tr["lot_attribute15"].ToString().Trim();
                                else
                                    cb_in_lot_attribute15.SelectedValue = "";
                            }
                        }
                    }
                }
                catch (System.Exception ee)
                {
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to get Information of sku batch attribute", main.g_info_dataset) + "!" + ee.ToString());
                    return;
                }

            }
            else
            {
                tb_transfer_lot_attribute1.Text = tr["lot_attribute1"].ToString().Trim();
                tb_transfer_lot_attribute2.Text = tr["lot_attribute2"].ToString().Trim();
                tb_transfer_lot_attribute3.Text = tr["lot_attribute3"].ToString().Trim();
                tb_transfer_lot_attribute4.Text = tr["lot_attribute4"].ToString().Trim();
                tb_transfer_lot_attribute5.Text = tr["lot_attribute5"].ToString().Trim();
                tb_transfer_lot_attribute6.Text = tr["lot_attribute6"].ToString().Trim();
                tb_transfer_lot_attribute7.Text = tr["lot_attribute7"].ToString().Trim();
                tb_transfer_lot_attribute8.Text = tr["lot_attribute8"].ToString().Trim();
                tb_transfer_lot_attribute9.Text = tr["lot_attribute9"].ToString().Trim();
                tb_transfer_lot_attribute10.Text = tr["lot_attribute10"].ToString().Trim();
                tb_transfer_lot_attribute11.Text = tr["lot_attribute11"].ToString().Trim();
                tb_transfer_lot_attribute12.Text = tr["lot_attribute12"].ToString().Trim();
                tb_transfer_lot_attribute13.Text = tr["lot_attribute13"].ToString().Trim();
                tb_transfer_lot_attribute14.Text = tr["lot_attribute14"].ToString().Trim();
                tb_transfer_lot_attribute15.Text = tr["lot_attribute15"].ToString().Trim();
                //哪些属性需要显示
                DataSet ds_attribute_tmp;
                string str_lotflag;
                try
                {
                    str_common = "select lot01flag,lot02flag,lot03flag,lot04flag,lot05flag,lot06flag,lot07flag,lot08flag,lot09flag,lot10flag,lot11flag,lot12flag,lot13flag," +
                                 "lot14flag,lot15flag,lot01label,lot02label,lot03label,lot04label,lot05label,lot06label,lot07label,lot08label,lot09label,lot10label," +
                                 "lot11label,lot12label,lot13label,lot14label,lot15label " +
                                 "from " + main.g_space + ".mst_sku a," + main.g_space + ".mst_attribute b where a.inv_org = '" + main.g_org + "' and a.consignor = '" + tr["consignor"].ToString().Trim() + "' and a.sku = '" + tr["sku"].ToString().Trim() + "' and a.lotno = b.lotno and a.inv_org = b.inv_org";
                    if (main.dbtype == "SQL")
                    {
                        ds_attribute_tmp = main.dbservice.Sql_exec_selectsql(str_common);
                    }
                    else
                    {
                        ds_attribute_tmp = main.dbservice.oracle_exec_selectsql(str_common);
                    }
                    lb_transfer_lot_attribute1.Text = main.g_class.comm_getchangestring("Production date", main.g_info_dataset);
                    lb_transfer_lot_attribute2.Text = main.g_class.comm_getchangestring("Putaway date", main.g_info_dataset);
                    if (ds_attribute_tmp.Tables[0].Rows.Count > 0) //说明有批次属性，从3开始
                    {
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot03flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_transfer_lot_attribute3.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot03label"].ToString().Trim(), main.g_info_dataset);
                            lb_transfer_lot_attribute3.Visible = true;
                            tb_transfer_lot_attribute3.Visible = true;
                        }
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot04flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_transfer_lot_attribute4.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot04label"].ToString().Trim(), main.g_info_dataset);
                            lb_transfer_lot_attribute4.Visible = true;
                            tb_transfer_lot_attribute4.Visible = true;
                        }
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot05flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_transfer_lot_attribute5.Visible = true;
                            tb_transfer_lot_attribute5.Visible = true;
                            lb_transfer_lot_attribute5.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot05label"].ToString().Trim(), main.g_info_dataset);
                        }
                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot06flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_transfer_lot_attribute6.Visible = true;
                            tb_transfer_lot_attribute6.Visible = true;
                            lb_transfer_lot_attribute6.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot06label"].ToString().Trim(), main.g_info_dataset);
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot07flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_transfer_lot_attribute7.Visible = true;
                            tb_transfer_lot_attribute7.Visible = true;
                            lb_transfer_lot_attribute7.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot07label"].ToString().Trim(), main.g_info_dataset);
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot08flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_transfer_lot_attribute8.Visible = true;
                            tb_transfer_lot_attribute8.Visible = true;
                            lb_transfer_lot_attribute8.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot08label"].ToString().Trim(), main.g_info_dataset);
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot09flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_transfer_lot_attribute9.Visible = true;
                            tb_transfer_lot_attribute9.Visible = true;
                            lb_transfer_lot_attribute9.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot09label"].ToString().Trim(), main.g_info_dataset);
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot10flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_transfer_lot_attribute10.Visible = true;
                            tb_transfer_lot_attribute10.Visible = true;
                            lb_transfer_lot_attribute10.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot10label"].ToString().Trim(), main.g_info_dataset);
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot11flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_transfer_lot_attribute11.Visible = true;
                            tb_transfer_lot_attribute11.Visible = true;
                            lb_transfer_lot_attribute11.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot11label"].ToString().Trim(), main.g_info_dataset);
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot12flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_transfer_lot_attribute12.Visible = true;
                            tb_transfer_lot_attribute12.Visible = true;
                            lb_transfer_lot_attribute12.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot12label"].ToString().Trim(), main.g_info_dataset);
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot13flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_transfer_lot_attribute13.Visible = true;
                            tb_transfer_lot_attribute13.Visible = true;
                            lb_transfer_lot_attribute13.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot13label"].ToString().Trim(), main.g_info_dataset);
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot14flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_transfer_lot_attribute14.Visible = true;
                            tb_transfer_lot_attribute14.Visible = true;
                            lb_transfer_lot_attribute14.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot14label"].ToString().Trim(), main.g_info_dataset);
                        }

                        str_lotflag = ds_attribute_tmp.Tables[0].Rows[0]["lot15flag"].ToString().Trim();
                        if (str_lotflag == "1") //说明可用，可见
                        {
                            lb_transfer_lot_attribute15.Visible = true;
                            tb_transfer_lot_attribute15.Visible = true;
                            lb_transfer_lot_attribute15.Text = main.g_class.comm_getchangestring(ds_attribute_tmp.Tables[0].Rows[0]["lot15label"].ToString().Trim(), main.g_info_dataset);
                        }
                    }
                }
                catch (System.Exception ee)
                {
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to get Information of sku batch attribute", main.g_info_dataset) + "!" + ee.ToString());
                    return;
                }
            }

        }
        private void dg_show_tan(DataRow tr)
        {


            tb_transfer_sku.Text = tr["sku"].ToString();
            cbx_transcust.Text = tr["consignor"].ToString();
            tb_transcustname.Text = main.g_class.comm_findname(cbx_transcust.Text.Trim(), newdscustomer);
            tb_transfer_order_price.Text = tr["order_price"].ToString();

            tb_transfer_order_unit.Text = tr["order_unit"].ToString();
            //tb_transcustname.Text = tr["consignor"].ToString();
            tb_transfer_location_code.Text = tr["location_code"].ToString();
            tb_transfer_pallet_no.Text = tr["pallet_no"].ToString();
            tb_transfer_qty_m.Text = tr["stock_qty_m"].ToString();
            tb_transfer_qty_s.Text = tr["stock_qty_s"].ToString();
            tb_transfer_net_weight.Text = tr["net_weight"].ToString();
            tb_transfer_gross_weight.Text = tr["gross_weight"].ToString();
            tb_transfer_cubage.Text = tr["cubage"].ToString();
        }

        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            //if (dataGridView1.CurrentRow != null)
            //{
            //    int i_tmp = dataGridView1.CurrentRow.Index;
            //    str_sql_where = " inv_org = '" + main.g_org + "' and batchno='" + dataGridView1.Rows[i_tmp].Cells["batchno"].EditedFormattedValue.ToString().Trim() + "'";
            //    str_sql_where += " and pallet_no='" + dataGridView1.Rows[i_tmp].Cells["pallet_no"].EditedFormattedValue.ToString().Trim() + "'";
            //    str_sql_where += " and location_code='" + dataGridView1.Rows[i_tmp].Cells["location_code"].EditedFormattedValue.ToString().Trim() + "'";

            //    DataRow[] tr = dspallet.Tables[0].Select(str_sql_where);
            //    if (tr.Length > 0)
            //    {
            //        dg_show_tan(tr[0]);
            //        //str_sql = "select * from " + main.g_space + ".inv_sku_batchno where batchno='" + tr[0]["batchno"] + "'";
            //        str_sqls = "select * from " + main.g_space + ".inv_sku_batchno   where inv_org = '" + main.g_org + "' and batchno='" + tr[0]["batchno"].ToString().Trim() + "'";
            //        try
            //        {
            //            if (main.dbtype == "SQL")
            //            {
            //                dsbatchno = main.dbservice.Sql_exec_selectsql(str_sqls);
            //            }
            //            else
            //            {
            //                dsbatchno = main.dbservice.oracle_exec_selectsql(str_sqls);
            //            }
            //            if (dsbatchno.Tables[0].Rows.Count > 0)
            //            {
            //                f_displayputaway(dsbatchno.Tables[0].Rows[0], 1);
            //            }
            //            this.btn_cancel.Enabled = true;
            //            this.btn_save.Enabled = true;
            //        }
            //        catch (System.Exception ee)
            //        {
            //            MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
            //        }
            //    }

            //}
        }

        private void dataGridView1_Click(object sender, EventArgs e)
        {
            //if (dataGridView1.CurrentRow != null)
            //{
            //    #region 
            //    dsbatchno = new DataSet();
            //    string batchno = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["batchno"].EditedFormattedValue.ToString().Trim();
            //    str_sqls = "select * from " + main.g_space + ".inv_sku_batchno  where inv_org = '" + main.g_org + "' and batchno='" + batchno + "'";
            //    try
            //    {
            //        if (main.dbtype == "SQL")
            //        {
            //            dsbatchno = main.dbservice.Sql_exec_selectsql(str_sqls);

            //        }
            //        else
            //        {
            //            dsbatchno = main.dbservice.oracle_exec_selectsql(str_sqls);
            //        }
            //        if (dsbatchno.Tables[0].Rows.Count > 0)
            //        {
            //            f_displayputaway(dsbatchno.Tables[0].Rows[0], 2);
            //            cbx_transcust.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_consignor"].Value.ToString();
            //            tb_transfer_sku.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_sku"].Value.ToString();
            //            tb_transfer_location_code.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_location_code"].Value.ToString();
            //            tb_convert_modulus.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["convert_modulus"].Value.ToString();
            //            cbx_packcode.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pack_code"].Value.ToString();
            //            tb_transfer_pallet_no.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pallet_no"].Value.ToString();
            //            tb_transfer_qty_m.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_m"].Value.ToString();
            //            tb_transfer_qty_s.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_s"].Value.ToString();
            //            tb_memo.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["memo"].Value.ToString();
            //            if (dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value.ToString().Trim() != "")
            //            {
            //                tb_transfer_order_price.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value.ToString();
            //            }
            //            else
            //            {
            //                tb_transfer_order_price.Text = "0";
            //            }
            //            tb_transfer_order_unit.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_unit"].Value.ToString();

            //            tb_transfer_cubage.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["cubage"].Value.ToString();
            //            tb_transfer_gross_weight.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_gross_weight"].Value.ToString();
            //            tb_transfer_net_weight.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_net_weight"].Value.ToString();
            //            if (dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["dist"].Value.ToString() == "1")
            //            {
            //                ClearCntrValue(this.groupBox5, true, "1");
            //                cbx_transcust.Enabled = true;
            //                cbx_packcode.Enabled = true;
            //            }
            //            else
            //            {
            //                ClearCntrValue(this.groupBox5, false, "1");
            //                cbx_transcust.Enabled = false;
            //                cbx_packcode.Enabled = false;
            //            }
            //        }

            //    }
            //    catch (System.Exception ee)
            //    {
            //        // MessageBox.Show("提取查询信息失败!" + ee.ToString());
            //        MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
            //    }
            //    #endregion 

           
               
            //        DataSet ds_te;
            //        //str_sql = "select * from " + main.g_space + ".inv_sku_batchno where batchno='" + tr[0]["batchno"] + "'";
            //        str_sqls = "select * from " + main.g_space + ".inv_sku_batchno   where inv_org = '" + main.g_org + "' and batchno='" + dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["batchno"].EditedFormattedValue.ToString().Trim() + "'";
            //        try
            //        {
            //            if (main.dbtype == "SQL")
            //            {
            //                ds_te = main.dbservice.Sql_exec_selectsql(str_sqls);
            //            }
            //            else
            //            {
            //                ds_te = main.dbservice.oracle_exec_selectsql(str_sqls);
            //            }
            //            if (ds_te.Tables[0].Rows.Count > 0)
            //            {
            //                f_displayputaway(ds_te.Tables[0].Rows[0], 1);
            //            }
            //            //this.btn_cancel.Enabled = true;
            //            //this.btn_save.Enabled = true;
            //        }
            //        catch (System.Exception ee)
            //        {
            //            MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
            //        }
               

                
            //}
        }

        private void cb_consignor_TextChanged(object sender, EventArgs e)
        {
            string str_cust;
            str_cust = cb_consignor.Text.Trim();
            tb_cusname.Text = main.g_class.comm_findname(str_cust, dscustomer);
        }
        private void Judge()
        {
            DataSet ds_str = new DataSet();
            string str = "";
            string str_pallet_flag, str_sql;
            DataSet ds_pallet_flag = new DataSet();
            str_sql = "select pallet_flag from " + main.g_space + ".mst_sku where inv_org = '" + main.g_org + "' and consignor='" + cbx_transcust.Text.Trim() + "' and sku = '" + tb_transfer_sku.Text.Trim() + "' ";
            if (main.dbtype == "SQL")
                ds_pallet_flag = main.dbservice.Sql_exec_selectsql(str_sql);
            else
                ds_pallet_flag = main.dbservice.oracle_exec_selectsql(str_sql);
            if (ds_pallet_flag.Tables[0].Rows.Count > 0)
            {
                str_pallet_flag = ds_pallet_flag.Tables[0].Rows[0][0].ToString().Trim();
                if (str_pallet_flag == "0")
                {
                    if (main.dbtype == "SQL")
                        str = "select leftcount  from " + main.g_space + ".SQL_NOPL_LOC where inv_org = '" + main.g_org + "' and location_code='" + tb_transfer_location_code.Text.Trim() + "'";
                    else
                        str = "select leftcount  from " + main.g_space + ".VIEW_ORL_NOPL_LOC where inv_org = '" + main.g_org + "' and location_code='" + tb_transfer_location_code.Text.Trim() + "'";
                }
                else
                {
                    if (main.dbtype == "SQL")
                        str = "select leftcount  from " + main.g_space + ".VIEW_SQL_PL_LOC where inv_org = '" + main.g_org + "' and location_code='" + tb_transfer_location_code.Text.Trim() + "'";
                    else
                        str = "select leftcount  from " + main.g_space + ".VIEW_ORL_PL_LOC where inv_org = '" + main.g_org + "' and location_code='" + tb_transfer_location_code.Text.Trim() + "'";
                }


                if (main.dbtype == "SQL")
                {
                    ds_str = main.dbservice.Sql_exec_selectsql(str);
                }
                else
                {
                    ds_str = main.dbservice.oracle_exec_selectsql(str);
                }
                if (ds_str.Tables[0].Rows.Count > 0)
                {
                    if (Convert.ToDecimal(tb_transfer_qty_m.Text.Trim()) > Convert.ToDecimal(ds_str.Tables[0].Rows[0][0].ToString().Trim()))//判断库位是否可用
                    {
                        MessageBox.Show(main.g_class.comm_getchangestring("" + tb_transfer_location_code.Text.Trim() + "Location code lack of capacity can not be moved sku", main.g_info_dataset) + "!");
                        return;

                        //str = "select pallet_flag from " + main.g_space + ".mst_sku where  sku='" + cb_moveout_sku.Text.Trim() + "' and consignor='" + cbx_h_consignor.Text.Trim() + "'";
                        //if (main.dbtype == "SQL")
                        //{
                        //    ds_str = main.dbservice.Sql_exec_selectsql(str);
                        //}
                        //else
                        //{
                        //    ds_str = main.dbservice.oracle_exec_selectsql(str);
                        //}
                        //if (ds_str.Tables[0].Rows[0]["pallet_flag"].ToString().Trim() == "1")//判断该商品是否是托盘
                        //{
                        //    str = "select count(*) from " + main.g_space + ".inv_sku_pallet where  pallet_no='" + cb_movein_pallet.Text.Trim() + "'";
                        //    if (main.dbtype == "SQL")
                        //    {
                        //        ds_str = main.dbservice.Sql_exec_selectsql(str);
                        //    }
                        //    else
                        //    {
                        //        ds_str = main.dbservice.oracle_exec_selectsql(str);
                        //    }
                        //    if (Convert.ToInt32(ds_str.Tables[0].Rows[0][0]) > 0)//判断托盘是否存在
                        //    {
                        //        str = "select b.qty04-a.stock_qty_m  from " + main.g_space + ".inv_sku_pallet a left join " + main.g_space + ".mst_pack b on a.pack_code=b.pack_code where a.location_code='" + cb_movein_pallet.Text.Trim() + "' and a.pallet_no='" + cb_movein_pallet.Text.Trim() + "'";
                        //        if (main.dbtype == "SQL")
                        //        {
                        //            ds_str = main.dbservice.Sql_exec_selectsql(str);
                        //        }
                        //        else
                        //        {
                        //            ds_str = main.dbservice.oracle_exec_selectsql(str);
                        //        }
                        //        if (Convert.ToInt32(ds_str.Tables[0].Rows[0][0]) < Convert.ToInt32(tb_move_qty_m.Text.Trim()))
                        //        {
                        //            MessageBox.Show("该" + tb_movein_location.Text.Trim() + "库位下托盘:" + cb_movein_pallet.Text.Trim() + "的容量不足不能存放!");
                        //            return;
                        //        }
                        //    }
                        //    else
                        //    {
                        //        if (main.dbtype == "SQL")
                        //        {
                        //            str = "select * from " + main.g_space + ".VIEW_SQL_PL_LOC where  location_code='" + cb_movein_pallet.Text.Trim() + "'";
                        //            ds_str = main.dbservice.Sql_exec_selectsql(str);
                        //        }
                        //        else
                        //        {
                        //            str = "select * from " + main.g_space + ".VIEW_ORL_PL_LOC where  location_code='" + cb_movein_pallet.Text.Trim() + "'";
                        //            ds_str = main.dbservice.oracle_exec_selectsql(str);
                        //        }
                        //        if (Convert.ToInt32(ds_str.Tables[0].Rows[0]["leftcount"]) <= 0)//否可以放入托盘
                        //        {
                        //            MessageBox.Show("该" + tb_movein_location.Text.Trim() + "库位下不能存放!");
                        //            return;
                        //        }
                        //    }

                        //}
                        //else
                        //{//非托盘
                        //    if (main.dbtype == "SQL")
                        //    {
                        //        str = "select * from " + main.g_space + ".VIEW_SQL_NOPL_LOC where  location_code='" + tb_movein_location.Text.Trim() + "'";
                        //        ds_str = main.dbservice.Sql_exec_selectsql(str);
                        //    }
                        //    else
                        //    {
                        //        str = "select * from " + main.g_space + ".VIEW_ORL_NOPL_LOC where  location_code='" + tb_movein_location.Text.Trim() + "'";
                        //        ds_str = main.dbservice.oracle_exec_selectsql(str);
                        //    }
                        //    if (Convert.ToInt32(ds_str.Tables[0].Rows[0]["leftcount"]) < Convert.ToInt32(tb_move_qty_m.Text.Trim()))
                        //    {
                        //        MessageBox.Show("该" + tb_movein_location.Text.Trim() + "库位不能存放!");
                        //        return;
                        //    }

                        //}

                    }
                }
            }
        }

        private void btn_save_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count > 0)
            {
                string str_transferno = "", s_sql = "", s_consignor = "";
                int i_line = 0;
                ArrayList al = new ArrayList();
                //得到转移单号
                str_transferno = main.g_class.comm_getaccountno("trans_no").Trim();
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    #region 增加明细
                    s_sql = "";
                    if (dataGridView1.Rows[i].Cells["dist"].Value.ToString().Trim() == "1")
                    {
                        i_line++;
                        if (s_consignor == "")
                        {
                            s_consignor = dataGridView1.Rows[i].Cells["consignor"].Value.ToString().Trim();
                        }
                        else
                        {
                            if (s_consignor != dataGridView1.Rows[i].Cells["consignor"].Value.ToString().Trim())
                            {
                                MessageBox.Show("必须选择同一个货主进行转移!");
                                return;
                            }
                        }
                        try
                        {
                            s_sql = "insert into " + main.g_space + ".inv_transfer_detail (	" +
                                    " inv_org,consignor,transfer_no,transfer_line_no," +
                                    " batchno,sku,order_price,order_unit," +
                                    " location_code,pallet_no,stock_qty_m,stock_qty_s," +
                                    " cubage,gross_weight,net_weight,lot_attribute1," +
                                    " lot_attribute2,lot_attribute3,lot_attribute4,lot_attribute5," +
                                    " lot_attribute6,lot_attribute7,lot_attribute8,lot_attribute9," +
                                    " lot_attribute10,lot_attribute11,lot_attribute12,lot_attribute13," +
                                    " lot_attribute14,lot_attribute15,main_sub_flag,convert_modulus," +
                                    " transfer_sku,	transfer_pack_code,transfer_order_price,transfer_order_unit,transfer_consignor," +
                                    " transfer_location_code,transfer_pallet_no,transfer_qty_m,transfer_qty_s," +
                                    " transfer_cubage,transfer_gross_weight,transfer_net_weight,transfer_lot_attribute1," +
                                    " transfer_lot_attribute2,transfer_lot_attribute3,transfer_lot_attribute4,transfer_lot_attribute5," +
                                    " transfer_lot_attribute6,transfer_lot_attribute7,transfer_lot_attribute8,transfer_lot_attribute9," +
                                    " transfer_lot_attribute10,transfer_lot_attribute11,transfer_lot_attribute12,transfer_lot_attribute13," +
                                    " transfer_lot_attribute14,transfer_lot_attribute15," +
                                    " transfer_status,confirm_day,confirmer,main_dist,made_time,maker,memo" +
                                    " ) values('" + main.g_org + "','" + dataGridView1.Rows[i].Cells["consignor"].Value.ToString().Trim() + "','" + str_transferno + "'," + i_line;

                            s_sql += ",'" + dataGridView1.Rows[i].Cells["batchno"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["sku"].Value.ToString().Trim() + "'," + dataGridView1.Rows[i].Cells["order_price"].Value.ToString().Trim() + ",'" + dataGridView1.Rows[i].Cells["order_unit"].Value.ToString().Trim() + "'";
                            s_sql += ",'" + dataGridView1.Rows[i].Cells["location_code"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["pallet_no"].Value.ToString().Trim() + "'," + dataGridView1.Rows[i].Cells["stock_qty_m"].Value.ToString().Trim() + "," + dataGridView1.Rows[i].Cells["stock_qty_s"].Value.ToString().Trim();
                            s_sql += "," + dataGridView1.Rows[i].Cells["cubage"].Value.ToString().Trim() + "," + dataGridView1.Rows[i].Cells["gross_weight"].Value.ToString().Trim() + "," + dataGridView1.Rows[i].Cells["net_weight"].Value.ToString().Trim() + ",'" + dataGridView1.Rows[i].Cells["lot_attribute1"].Value.ToString().Trim() + "'";
                            s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute2"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["lot_attribute3"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["lot_attribute4"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["lot_attribute5"].Value.ToString().Trim() + "'";
                            s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute6"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["lot_attribute7"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["lot_attribute8"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["lot_attribute9"].Value.ToString().Trim() + "'";
                            s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute10"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["lot_attribute11"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["lot_attribute12"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["lot_attribute13"].Value.ToString().Trim() + "'";
                            s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute14"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["lot_attribute15"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["main_sub_flag"].Value.ToString().Trim() + "'," + dataGridView1.Rows[i].Cells["convert_modulus"].Value.ToString().Trim();
                            s_sql += ",'" + dataGridView1.Rows[i].Cells["tr_sku"].Value.ToString().Trim() + "','"+dataGridView1.Rows[i].Cells["tr_pack_code"].Value.ToString().Trim()+"'," + dataGridView1.Rows[i].Cells["tr_order_price"].Value.ToString().Trim() + ",'" + dataGridView1.Rows[i].Cells["tr_order_unit"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["tr_consignor"].Value.ToString().Trim() + "'";
                            s_sql += ",'" + dataGridView1.Rows[i].Cells["tr_location_code"].Value.ToString().Trim() + "','" + dataGridView1.Rows[i].Cells["tr_pallet_no"].Value.ToString().Trim() + "'," + dataGridView1.Rows[i].Cells["transfer_qty_m"].Value.ToString().Trim() + "," + dataGridView1.Rows[i].Cells["transfer_qty_s"].Value.ToString().Trim();
                             s_sql += "," + dataGridView1.Rows[i].Cells["tr_cubage"].Value.ToString().Trim() + "," + dataGridView1.Rows[i].Cells["tr_gross_weight"].Value.ToString().Trim() + "," + dataGridView1.Rows[i].Cells["tr_net_weight"].Value.ToString().Trim();
                             if (tb_in_lot_attribute1.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute1"].Value.ToString().Trim())//1
                            {
                                s_sql += ",'" + tb_in_lot_attribute1.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute1"].Value.ToString().Trim() + "'";
                            }
                            if (tb_in_lot_attribute2.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute2"].Value.ToString().Trim())//2
                            {
                                s_sql += ",'" + tb_in_lot_attribute2.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute2"].Value.ToString().Trim() + "'";
                            }
                            if (cb_in_lot_attribute3.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute3"].Value.ToString().Trim())//3
                            {
                                s_sql += ",'" + cb_in_lot_attribute3.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute3"].Value.ToString().Trim() + "'";
                            }
                            if (cb_in_lot_attribute4.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute4"].Value.ToString().Trim())//4
                            {
                                s_sql += ",'" + cb_in_lot_attribute4.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute4"].Value.ToString().Trim() + "'";
                            }
                            if (cb_in_lot_attribute5.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute5"].Value.ToString().Trim())//5
                            {
                                s_sql += ",'" + cb_in_lot_attribute5.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute5"].Value.ToString().Trim() + "'";
                            }
                            if (cb_in_lot_attribute6.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute6"].Value.ToString().Trim())//6
                            {
                                s_sql += ",'" + cb_in_lot_attribute6.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute6"].Value.ToString().Trim() + "'";
                            }
                            if (cb_in_lot_attribute7.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute7"].Value.ToString().Trim())//7
                            {
                                s_sql += ",'" + cb_in_lot_attribute7.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute7"].Value.ToString().Trim() + "'";
                            }
                            if (cb_in_lot_attribute8.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute8"].Value.ToString().Trim())//8
                            {
                                s_sql += ",'" + cb_in_lot_attribute8.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute8"].Value.ToString().Trim() + "'";
                            }
                            if (cb_in_lot_attribute9.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute9"].Value.ToString().Trim())//9
                            {
                                s_sql += ",'" + cb_in_lot_attribute9.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute9"].Value.ToString().Trim() + "'";
                            }
                            if (cb_in_lot_attribute10.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute10"].Value.ToString().Trim())//10
                            {
                                s_sql += ",'" + cb_in_lot_attribute10.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute10"].Value.ToString().Trim() + "'";
                            }
                            if (cb_in_lot_attribute11.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute11"].Value.ToString().Trim())//11
                            {
                                s_sql += ",'" + cb_in_lot_attribute11.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute11"].Value.ToString().Trim() + "'";
                            }
                            if (cb_in_lot_attribute12.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute12"].Value.ToString().Trim())//12
                            {
                                s_sql += ",'" + cb_in_lot_attribute12.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute12"].Value.ToString().Trim() + "'";
                            }
                            if (cb_in_lot_attribute13.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute13"].Value.ToString().Trim())//13
                            {
                                s_sql += ",'" + cb_in_lot_attribute13.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute13"].Value.ToString().Trim() + "'";
                            }
                            if (cb_in_lot_attribute14.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute14"].Value.ToString().Trim())//14
                            {
                                s_sql += ",'" + cb_in_lot_attribute14.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute14"].Value.ToString().Trim() + "'";
                            }
                            if (cb_in_lot_attribute15.Text.Trim() != dataGridView1.Rows[i].Cells["lot_attribute15"].Value.ToString().Trim())//15
                            {
                                s_sql += ",'" + cb_in_lot_attribute15.Text.Trim() + "'";
                            }
                            else
                            {
                                s_sql += ",'" + dataGridView1.Rows[i].Cells["lot_attribute15"].Value.ToString().Trim() + "'";
                            }
                            if (main.dbtype == "SQL")
                            {
                                s_sql += ",'1',CONVERT(VARCHAR(10),GETDATE(),102),'" + main.g_user + "','A',GETDATE(),'" + main.g_user + "','" + dataGridView1.Rows[i].Cells["memo"].Value.ToString().Trim() + "')"; 
                            }
                            else
                            {
                                s_sql += ",'1',to_char(sysdate,'YYYY.MM.DD'),'" + main.g_user + "','A',sysdate,'" + main.g_user + "','" + dataGridView1.Rows[i].Cells["memo"].Value.ToString().Trim() + "')";
                            }
                        }
                        catch (System.Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                            return;
                        }
                        al.Add(s_sql);
                    }
                    #endregion
                }
                if (al.Count > 0)
                {
                    if (main.dbtype == "SQL")
                    {
                        s_sql = "insert into " + main.g_space + ".inv_transfer_header (inv_org,transfer_no,transfer_type," +
                                  "  transfer_reason,transfer_status,main_dist,made_time,maker" +
                               " ) values('" + main.g_org + "','" + str_transferno + "','0','','0','A',getdate(),'" + main.g_user + "')";
                    }
                    else
                    {
                        s_sql = "insert into " + main.g_space + ".inv_transfer_header (inv_org,transfer_no,transfer_type," +
                                     "  transfer_reason,transfer_status,main_dist,made_time,maker" +
                                  " ) values('" + main.g_org + "','" + str_transferno + "','0','','0','A',sysdate,'" + main.g_user + "')";
                    }
                    string[] str_list = new string[al.Count + 1];
                    for (int i = 0; i < al.Count; i++)
                    {
                        str_list[i] = al[i].ToString().Trim();
                    }
                    str_list[str_list.Length - 1] = s_sql;
                    //if (main.dbtype == "SQL")
                    //{
                    //    main.dbservice.Sql_exec_mutilsql(str_list);
                    //}
                    //else
                    //{
                    //    main.dbservice.oracle_exec_mutilsql(str_list);
                    //}
                    try
                    {
                        string str_message = "";
                        if (main.dbtype == "SQL")
                            str_message=main.dbservice.Sql_exec_proc_transfer_js(main.g_org, str_list, s_consignor, str_transferno, "0", main.g_user);
                        else
                           // str_message=main.dbservice.oracle_exec_proc_transfer(main.g_org, str_list, s_consignor, str_transferno, "0", main.g_user);

                        if (str_message.Trim() == "") 
                        {
                            MessageBox.Show("转移成功");
                            //刷新信息
                            btn_Query_Click(sender, new EventArgs());
                            
                        }
                    }

                    catch (System.Exception ee)
                    {

                        MessageBox.Show(main.g_class.comm_getchangestring("Fail to Save", main.g_info_dataset) + "!" + ee.ToString());
                    }
                   
                    
                }

            }

        }

        private void tb_transfer_qty_m_TextChanged(object sender, EventArgs e)
        {
            if (tb_transfer_qty_m.Text.Trim() != "")
                tb_transfer_qty_s.Text = Convert.ToString(Math.Round(Convert.ToDecimal(tb_transfer_qty_m.Text.Trim()) * Convert.ToDecimal(tb_convert_modulus.Text.Trim()), 4));
        }

        private void tb_transfer_sku_TextChanged(object sender, EventArgs e)
        {
            if (tb_transfer_sku.Text.Trim() != "" && cbx_transcust.Text.Trim() != "")
                f_initpactcode(cbx_transcust.Text.Trim(), tb_transfer_sku.Text.Trim());

        }

        private void cbx_transcust_TextChanged(object sender, EventArgs e)
        {
            string str_cust;
            str_cust = cbx_transcust.Text.Trim();
            tb_transcustname.Text = main.g_class.comm_findname(str_cust, newdscustomer);
            if (tb_transfer_sku.Text.Trim() != "" && str_cust != "")
                f_initpactcode(str_cust, tb_transfer_sku.Text.Trim());
        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            i_trans_header = e.ColumnIndex;
        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            ClearCntrValue(this.groupBox5, true, "0");
            ClearCntrValue(this.groupBox7, true, "0");
            btn_cancel.Enabled = false;
            btn_save.Enabled = false;
        }

        private void dataGridView1_Sorted(object sender, EventArgs e)
        {
            //if (dataGridView1.CurrentRow != null)
            //{
            //    string str_headertext;
            //    //先删除合计行
            //    ((DataTable)dataGridView1.DataSource).Rows.Remove(((DataTable)dataGridView1.DataSource).Select("pack_code = '合计'")[0]);
            //    //然后对Tables[0]重新排序
            //    DataTable dt;
            //    DataView dv = ((DataTable)dataGridView1.DataSource).DefaultView;
            //    //得到点击的列
            //    str_headertext = dataGridView1.Columns[i_trans_header].DataPropertyName.ToString().Trim();
            //    if (b_trans_sort) //升序
            //    {
            //        dv.Sort = str_headertext + " DESC";
            //        b_trans_sort = false;
            //    }
            //    else
            //    {
            //        dv.Sort = str_headertext;
            //        b_trans_sort = true;
            //    }
            //    dt = dv.ToTable();
            //    dataGridView1.DataSource = null;
            //    dataGridView1.DataSource = dt;
            //    //增加合计行
            //    f_add_trans();
            //}
        }

        private void tb_transfer_qty_m_Leave(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                try
                {
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_consignor"].Value = cbx_transcust.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_sku"].Value = tb_transfer_sku.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_location_code"].Value = tb_transfer_location_code.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pack_code"].Value = cbx_packcode.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pallet_no"].Value = tb_transfer_pallet_no.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_m"].Value = tb_transfer_qty_m.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_s"].Value = tb_transfer_qty_s.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value = tb_transfer_order_price.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_unit"].Value = tb_transfer_order_unit.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_cubage"].Value = tb_transfer_cubage.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_gross_weight"].Value = tb_transfer_gross_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_net_weight"].Value = tb_transfer_net_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["memo"].Value = tb_memo.Text.Trim();
                }
                catch (System.Exception ee)
                {
                    // MessageBox.Show("提取查询信息失败!" + ee.ToString());
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
                }
            }
        }

        private void cbx_transcust_Leave(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                try
                {
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_consignor"].Value = cbx_transcust.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_sku"].Value = tb_transfer_sku.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_location_code"].Value = tb_transfer_location_code.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pack_code"].Value = cbx_packcode.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pallet_no"].Value = tb_transfer_pallet_no.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_m"].Value = tb_transfer_qty_m.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_s"].Value = tb_transfer_qty_s.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value = tb_transfer_order_price.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_unit"].Value = tb_transfer_order_unit.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_cubage"].Value = tb_transfer_cubage.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_gross_weight"].Value = tb_transfer_gross_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_net_weight"].Value = tb_transfer_net_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["memo"].Value = tb_memo.Text.Trim();
                }
                catch (System.Exception ee)
                {
                    // MessageBox.Show("提取查询信息失败!" + ee.ToString());
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
                }
            }
        }

        private void tb_transfer_sku_Leave(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                try
                {
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_consignor"].Value = cbx_transcust.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_sku"].Value = tb_transfer_sku.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_location_code"].Value = tb_transfer_location_code.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pack_code"].Value = cbx_packcode.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pallet_no"].Value = tb_transfer_pallet_no.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_m"].Value = tb_transfer_qty_m.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_s"].Value = tb_transfer_qty_s.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value = tb_transfer_order_price.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_unit"].Value = tb_transfer_order_unit.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_cubage"].Value = tb_transfer_cubage.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_gross_weight"].Value = tb_transfer_gross_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_net_weight"].Value = tb_transfer_net_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["memo"].Value = tb_memo.Text.Trim();
                }
                catch (System.Exception ee)
                {
                    // MessageBox.Show("提取查询信息失败!" + ee.ToString());
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
                }
            }
        }

        private void tb_transfer_location_code_Leave(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                try
                {
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_consignor"].Value = cbx_transcust.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_sku"].Value = tb_transfer_sku.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_location_code"].Value = tb_transfer_location_code.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pack_code"].Value = cbx_packcode.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pallet_no"].Value = tb_transfer_pallet_no.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_m"].Value = tb_transfer_qty_m.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_s"].Value = tb_transfer_qty_s.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value = tb_transfer_order_price.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_unit"].Value = tb_transfer_order_unit.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_cubage"].Value = tb_transfer_cubage.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_gross_weight"].Value = tb_transfer_gross_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_net_weight"].Value = tb_transfer_net_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["memo"].Value = tb_memo.Text.Trim();
                }
                catch (System.Exception ee)
                {
                    // MessageBox.Show("提取查询信息失败!" + ee.ToString());
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
                }
            }
        }

        private void tb_transfer_pallet_no_Leave(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                try
                {
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_consignor"].Value = cbx_transcust.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_sku"].Value = tb_transfer_sku.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_location_code"].Value = tb_transfer_location_code.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pack_code"].Value = cbx_packcode.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pallet_no"].Value = tb_transfer_pallet_no.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_m"].Value = tb_transfer_qty_m.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_s"].Value = tb_transfer_qty_s.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value = tb_transfer_order_price.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_unit"].Value = tb_transfer_order_unit.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_cubage"].Value = tb_transfer_cubage.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_gross_weight"].Value = tb_transfer_gross_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_net_weight"].Value = tb_transfer_net_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["memo"].Value = tb_memo.Text.Trim();
                }
                catch (System.Exception ee)
                {
                    // MessageBox.Show("提取查询信息失败!" + ee.ToString());
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
                }
            }
        }

        private void tb_transfer_qty_s_Leave(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                try
                {
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_consignor"].Value = cbx_transcust.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_sku"].Value = tb_transfer_sku.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_location_code"].Value = tb_transfer_location_code.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pack_code"].Value = cbx_packcode.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pallet_no"].Value = tb_transfer_pallet_no.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_m"].Value = tb_transfer_qty_m.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_s"].Value = tb_transfer_qty_s.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value = tb_transfer_order_price.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_unit"].Value = tb_transfer_order_unit.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_cubage"].Value = tb_transfer_cubage.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_gross_weight"].Value = tb_transfer_gross_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_net_weight"].Value = tb_transfer_net_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["memo"].Value = tb_memo.Text.Trim();
                }
                catch (System.Exception ee)
                {
                    // MessageBox.Show("提取查询信息失败!" + ee.ToString());
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
                }
            }
        }

        private void tb_transfer_order_price_Leave(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                try
                {
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_consignor"].Value = cbx_transcust.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_sku"].Value = tb_transfer_sku.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_location_code"].Value = tb_transfer_location_code.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pack_code"].Value = cbx_packcode.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pallet_no"].Value = tb_transfer_pallet_no.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_m"].Value = tb_transfer_qty_m.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_s"].Value = tb_transfer_qty_s.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value = tb_transfer_order_price.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_unit"].Value = tb_transfer_order_unit.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_cubage"].Value = tb_transfer_cubage.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_gross_weight"].Value = tb_transfer_gross_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_net_weight"].Value = tb_transfer_net_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["memo"].Value = tb_memo.Text.Trim();
                }
                catch (System.Exception ee)
                {
                    // MessageBox.Show("提取查询信息失败!" + ee.ToString());
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
                }
            }
        }

        private void tb_transfer_order_unit_Leave(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                try
                {
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_consignor"].Value = cbx_transcust.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_sku"].Value = tb_transfer_sku.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_location_code"].Value = tb_transfer_location_code.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pack_code"].Value = cbx_packcode.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pallet_no"].Value = tb_transfer_pallet_no.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_m"].Value = tb_transfer_qty_m.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_s"].Value = tb_transfer_qty_s.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value = tb_transfer_order_price.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_unit"].Value = tb_transfer_order_unit.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_cubage"].Value = tb_transfer_cubage.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_gross_weight"].Value = tb_transfer_gross_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_net_weight"].Value = tb_transfer_net_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["memo"].Value = tb_memo.Text.Trim();
                }
                catch (System.Exception ee)
                {
                    // MessageBox.Show("提取查询信息失败!" + ee.ToString());
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
                }
            }
        }

        private void tb_transfer_cubage_Leave(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                try
                {
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_consignor"].Value = cbx_transcust.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_sku"].Value = tb_transfer_sku.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_location_code"].Value = tb_transfer_location_code.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pack_code"].Value = cbx_packcode.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pallet_no"].Value = tb_transfer_pallet_no.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_m"].Value = tb_transfer_qty_m.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_s"].Value = tb_transfer_qty_s.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value = tb_transfer_order_price.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_unit"].Value = tb_transfer_order_unit.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_cubage"].Value = tb_transfer_cubage.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_gross_weight"].Value = tb_transfer_gross_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_net_weight"].Value = tb_transfer_net_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["memo"].Value = tb_memo.Text.Trim();
                }
                catch (System.Exception ee)
                {
                    // MessageBox.Show("提取查询信息失败!" + ee.ToString());
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
                }
            }
        }

        private void tb_transfer_gross_weight_Leave(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                try
                {
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_consignor"].Value = cbx_transcust.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_sku"].Value = tb_transfer_sku.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_location_code"].Value = tb_transfer_location_code.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pack_code"].Value = cbx_packcode.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pallet_no"].Value = tb_transfer_pallet_no.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_m"].Value = tb_transfer_qty_m.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_s"].Value = tb_transfer_qty_s.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value = tb_transfer_order_price.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_unit"].Value = tb_transfer_order_unit.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_cubage"].Value = tb_transfer_cubage.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_gross_weight"].Value = tb_transfer_gross_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_net_weight"].Value = tb_transfer_net_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["memo"].Value = tb_memo.Text.Trim();
                }
                catch (System.Exception ee)
                {
                    // MessageBox.Show("提取查询信息失败!" + ee.ToString());
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
                }
            }
        }

        private void tb_transfer_net_weight_Leave(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                try
                {
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_consignor"].Value = cbx_transcust.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_sku"].Value = tb_transfer_sku.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_location_code"].Value = tb_transfer_location_code.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pack_code"].Value = cbx_packcode.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pallet_no"].Value = tb_transfer_pallet_no.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_m"].Value = tb_transfer_qty_m.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_s"].Value = tb_transfer_qty_s.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value = tb_transfer_order_price.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_unit"].Value = tb_transfer_order_unit.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_cubage"].Value = tb_transfer_cubage.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_gross_weight"].Value = tb_transfer_gross_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_net_weight"].Value = tb_transfer_net_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["memo"].Value = tb_memo.Text.Trim();
                }
                catch (System.Exception ee)
                {
                    // MessageBox.Show("提取查询信息失败!" + ee.ToString());
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
                }
            }
        }

        private void tb_transfer_qty_s_TextChanged(object sender, EventArgs e)
        {
            if (tb_transfer_qty_s.Text.Trim() != "")
                tb_transfer_qty_m.Text = Convert.ToString(Math.Round(Convert.ToDecimal(tb_transfer_qty_s.Text.Trim()) / Convert.ToDecimal(tb_convert_modulus.Text.Trim()), 4));
        }


        private void dataGridView1_CurrentCellDirtyStateChanged(object sender, EventArgs e)
        {
            if (dataGridView1.Columns[dataGridView1.CurrentCell.ColumnIndex].Name.ToString().Trim() == "dist")
            {
                if (dataGridView1.IsCurrentCellDirty)
                {
                    dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
                }
            }
        }





        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                if (dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["dist"].Value.ToString() == "1")
                {
                    ClearCntrValue(this.groupBox5, true, "1");
                    cbx_transcust.Enabled = true;
                    cbx_packcode.Enabled = true;
                }
                else
                {
                    ClearCntrValue(this.groupBox5, false, "1");
                    cbx_transcust.Enabled = false;
                    cbx_packcode.Enabled = false;
                }
            }
        }

        private void bt_all_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                dataGridView1.Rows[i].Cells["dist"].Value = 1;
            }
        }

        private void bt_reset_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1.Rows[i].Cells["dist"].Value.ToString().Trim() == "1")
                {
                    dataGridView1.Rows[i].Cells["dist"].Value = 0;
                }
                else
                {
                    dataGridView1.Rows[i].Cells["dist"].Value = 1;
                }

            }
        }

       

        private void cbx_transcust_SelectedIndexChanged(object sender, EventArgs e)
        {
            string str_cust;
            str_cust = cbx_transcust.Text.Trim();
            tb_transcustname.Text = main.g_class.comm_findname(str_cust, newdscustomer);
            if (tb_transfer_sku.Text.Trim() != "" && str_cust != "")
                f_initpactcode(str_cust, tb_transfer_sku.Text.Trim());
        }

        private void tb_transfer_cubage_TextChanged(object sender, EventArgs e)
        {

        }

        private void tb_memo_Leave(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                try
                {
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_consignor"].Value = cbx_transcust.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_sku"].Value = tb_transfer_sku.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_location_code"].Value = tb_transfer_location_code.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pack_code"].Value = cbx_packcode.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pallet_no"].Value = tb_transfer_pallet_no.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_m"].Value = tb_transfer_qty_m.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_s"].Value = tb_transfer_qty_s.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value = tb_transfer_order_price.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_unit"].Value = tb_transfer_order_unit.Text;
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_cubage"].Value = tb_transfer_cubage.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_gross_weight"].Value = tb_transfer_gross_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_net_weight"].Value = tb_transfer_net_weight.Text.Trim();
                    dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["memo"].Value = tb_memo.Text.Trim();
                }
                catch (System.Exception ee)
                {
                    // MessageBox.Show("提取查询信息失败!" + ee.ToString());
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
                }
            }
        }

        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                #region
                dsbatchno = new DataSet();
                string batchno = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["batchno"].EditedFormattedValue.ToString().Trim();
                str_sqls = "select * from " + main.g_space + ".inv_sku_batchno  where inv_org = '" + main.g_org + "' and batchno='" + batchno + "'";
                try
                {
                    if (main.dbtype == "SQL")
                    {
                        dsbatchno = main.dbservice.Sql_exec_selectsql(str_sqls);

                    }
                    else
                    {
                        dsbatchno = main.dbservice.oracle_exec_selectsql(str_sqls);
                    }
                    if (dsbatchno.Tables[0].Rows.Count > 0)
                    {
                        f_displayputaway(dsbatchno.Tables[0].Rows[0], 2);
                        cbx_transcust.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_consignor"].Value.ToString();
                        tb_transfer_sku.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_sku"].Value.ToString();
                        tb_transfer_location_code.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_location_code"].Value.ToString();
                        tb_convert_modulus.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["convert_modulus"].Value.ToString();
                        cbx_packcode.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pack_code"].Value.ToString();
                        tb_transfer_pallet_no.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_pallet_no"].Value.ToString();
                        tb_transfer_qty_m.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_m"].Value.ToString();
                        tb_transfer_qty_s.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["transfer_qty_s"].Value.ToString();
                        tb_memo.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["memo"].Value.ToString();
                        if (dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value.ToString().Trim() != "")
                        {
                            tb_transfer_order_price.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_price"].Value.ToString();
                        }
                        else
                        {
                            tb_transfer_order_price.Text = "0";
                        }
                        tb_transfer_order_unit.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_order_unit"].Value.ToString();

                        tb_transfer_cubage.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["cubage"].Value.ToString();
                        tb_transfer_gross_weight.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_gross_weight"].Value.ToString();
                        tb_transfer_net_weight.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["tr_net_weight"].Value.ToString();
                        if (dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["dist"].Value.ToString() == "1")
                        {
                            ClearCntrValue(this.groupBox5, true, "1");
                            cbx_transcust.Enabled = true;
                            cbx_packcode.Enabled = true;
                        }
                        else
                        {
                            ClearCntrValue(this.groupBox5, false, "1");
                            cbx_transcust.Enabled = false;
                            cbx_packcode.Enabled = false;
                        }
                    }

                }
                catch (System.Exception ee)
                {
                    // MessageBox.Show("提取查询信息失败!" + ee.ToString());
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
                }
                #endregion



                DataSet ds_te;
                //str_sql = "select * from " + main.g_space + ".inv_sku_batchno where batchno='" + tr[0]["batchno"] + "'";
                str_sqls = "select * from " + main.g_space + ".inv_sku_batchno   where inv_org = '" + main.g_org + "' and batchno='" + dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["batchno"].EditedFormattedValue.ToString().Trim() + "'";
                try
                {
                    if (main.dbtype == "SQL")
                    {
                        ds_te = main.dbservice.Sql_exec_selectsql(str_sqls);
                    }
                    else
                    {
                        ds_te = main.dbservice.oracle_exec_selectsql(str_sqls);
                    }
                    if (ds_te.Tables[0].Rows.Count > 0)
                    {
                        f_displayputaway(ds_te.Tables[0].Rows[0], 1);
                    }
                    //this.btn_cancel.Enabled = true;
                    //this.btn_save.Enabled = true;
                }
                catch (System.Exception ee)
                {
                    MessageBox.Show(main.g_class.comm_getchangestring("Fail to Query", main.g_info_dataset) + "!" + ee.ToString());
                }



            }
        }


    }
}